(global["webpackJsonp"] = global["webpackJsonp"] || []).push([
    ["pages/main/sales/create"], {
        "0596": function (t, e, o) {
            "use strict";
            o.d(e, "b", (function () {
                return n
            })), o.d(e, "c", (function () {
                return a
            })), o.d(e, "a", (function () {
                return i
            }));
            var i = {
                    uniForms: function () {
                        return Promise.all([o.e("common/vendor"), o.e("components/uni-forms/uni-forms")]).then(o.bind(null, "0933"))
                    },
                    uniFormsItem: function () {
                        return o.e("components/uni-forms-item/uni-forms-item").then(o.bind(null, "4828"))
                    },
                    dtSelect: function () {
                        return o.e("components/dt-select/dt-select").then(o.bind(null, "9fbf"))
                    },
                    uniEasyinput: function () {
                        return Promise.all([o.e("common/vendor"), o.e("components/uni-easyinput/uni-easyinput")]).then(o.bind(null, "5dad"))
                    },
                    uniSwipeAction: function () {
                        return o.e("components/uni-swipe-action/uni-swipe-action").then(o.bind(null, "e7b4"))
                    },
                    uniSwipeActionItem: function () {
                        return Promise.all([o.e("common/vendor"), o.e("components/uni-swipe-action-item/uni-swipe-action-item")]).then(o.bind(null, "c498"))
                    }
                },
                n = function () {
                    var t = this.$createElement;
                    this._self._c
                },
                a = []
        },
        3313: function (t, e, o) {
            "use strict";
            o.r(e);
            var i = o("0596"),
                n = o("457b");
            for (var a in n)["default"].indexOf(a) < 0 && function (t) {
                o.d(e, t, (function () {
                    return n[t]
                }))
            }(a);
            o("d543");
            var s = o("f0c5"),
                r = Object(s["a"])(n["default"], i["b"], i["c"], !1, null, "020cd288", null, !1, i["a"], void 0);
            e["default"] = r.exports
        },
        "457b": function (t, e, o) {
            "use strict";
            o.r(e);
            var i = o("c3c9"),
                n = o.n(i);
            for (var a in i)["default"].indexOf(a) < 0 && function (t) {
                o.d(e, t, (function () {
                    return i[t]
                }))
            }(a);
            e["default"] = n.a
        },
        "588d": function (t, e, o) {},
        "89a5": function (t, e, o) {
            "use strict";
            (function (t, e) {
                var i = o("4ea4");
                o("c150"), o("5c17"), o("a9ff");
                i(o("66fd"));
                var n = i(o("3313"));
                t.__webpack_require_UNI_MP_PLUGIN__ = o, e(n.default)
            }).call(this, o("bc2e")["default"], o("543d")["createPage"])
        },
        c3c9: function (t, e, o) {
            "use strict";
            (function (t) {
                var i = o("4ea4");
                Object.defineProperty(e, "__esModule", {
                    value: !0
                }), e.default = void 0;
                var n = i(o("2eee")),
                    a = i(o("c973"));
                i(o("0436"));

                function s(t) {
                    var e = new Date,
                        o = e.getFullYear(),
                        i = e.getMonth() + 1,
                        n = e.getDate();
                    return "start" === t ? o -= 10 : "end" === t && (o += 10), i = i > 9 ? i : "0" + i, n = n > 9 ? n : "0" + n, "".concat(o, "-").concat(i, "-").concat(n)
                }
                var r = {
                    components: {
                        dtSelect: function () {
                            o.e("components/dt-select/dt-select").then(function () {
                                return resolve(o("9fbf"))
                            }.bind(null, o)).catch(o.oe)
                        }
                    },
                    data: function () {
                        return {
                            yfk: 0,
                            kh: 0,
                            xs: 0,
                            finWeight: "0",
                            saleOrderState: !1,
                            sid: 0,
                            url: getApp().globalData.apiurl,
                            date: s({
                                format: !0
                            }),
                            dateend: s({
                                format: !0
                            }),
                            sl: 0, //税率
                            sf: 0,
                            zzl: 0,
                            zje: 0,
                            fhsj: "",
                            ddid: "",
                            listData: [],
                            startDate: s("start"),
                            endDate: s("end"),
                            customers: [],
                            paymentTypes: [],
                            goodsTypes: [],
                            goods: [],
                            roles: [],
                            orderStateUpdate: true,
                            ischeck: true,
                            ischeck1: false,
                          
                            model: {
                              customerName:null,
                                id: 0,
                                customerId: "",
                                goodId: "",
                                weight: 0,
                                unitPrice: 0,
                                totalPrice: 0,
                                roleId: "",
                                status: 0,
                                deliverytime: null,
                                approver2: "",
                                ordertime: "",
                                tax: 0, //税费
                                freight: 0, //运费
                                taxbtu: 0,
                                sizepackaging: "", // 包装规格
                                paymentType: "",
                            },
                            finalList: [],
                            rules: {
                                customerId: {
                                    rules: [{
                                        required: !0,
                                        errorMessage: "请选择客户"
                                    }]
                                },
                                roleId: {
                                    rules: [{
                                        required: !0,
                                        errorMessage: "请选择审批角色"
                                    }]
                                },
                                paymentType: {
                                    rules: [{
                                        required: !"",
                                        errorMessage: "请选择支付类型"
                                    }]
                                }
                            }
                        }
                    },
                    watch: {
                      "model.goodId": {
                        handler: function (t) {
                            console.log("good");
                           
                            this.model.sizepackaging=null;
                            console.info(this.model);
                        },
                        deep: !0
                    },
                        "model.sizepackaging": {
                            handler: function (t) {
                                // console.log("good");
                                if(this.model.sizepackaging!=null){
                                  this.getWeightGoods(t)
                                }
                            },
                            deep: !0
                        },
                        "model.customerId": {
                            handler: function (t) {
                                this.showLimit(t)
                            },
                            deep: !0
                        },
                        "model.paymentType": {
                            handler: function (e) {},
                        }
                    },
                    methods: {
                      showGoodsType(data){
                    
                        if(data==null){
                          return "吨包";
                        }
                          let item=this.goodsTypes.filter(val => val.dictValue==data);
                          return item[0].dictLabel;
                      },
                        JudgmentType: function (e) {
                            console.info("进入判断", e);
                            if (e == "") {
                                return false;
                            }
                            let _this = this;
                            if (_this.model.customerId == "") {

                                t.showToast({
                                    title: "请先选择客户",
                                    icon: "error",
                                    duration: 2e3
                                });
                                // _this.setData({
                                //     "model.paymentType":""  
                                // })
                                this.model.paymentType = null;
                                console.info(this.model.paymentType);
                                return false;
                            }

                            if (e == 0) {

                                if (_this.xs ==0) {

                                    t.showToast({
                                        title: "未赋予销售额度额度",
                                        icon: "error",
                                        duration: 2e3
                                    });
                                    _this.model.paymentType = "";
                                    return false;
                                }
                                if (_this.kh >0) {

                                    t.showToast({
                                        title: "客户已开启客户额度",
                                        icon: "error",
                                        duration: 2e3
                                    });
                                    _this.model.paymentType = "";
                                    return false;
                                }
                            }
                            if (e == 1) {
                                if (_this.kh == 0) {

                                    t.showToast({
                                        title: "未开启客户额度支付",
                                        icon: "error",
                                        duration: 2e3
                                    });
                                    _this.model.paymentType = "";
                                    return false;
                                }
                            }
                            if (e == 2) {
                                if (_this.yfk == 0) {
                                    console.info("未开预付款");
                                    t.showToast({
                                        title: "未开启预付款支付",
                                        icon: "error",
                                        duration: 2e3
                                    });
                                    _this.model.paymentType = "";
                                    return false;
                                }
                            }

                            return true;
                        },
                        showLimit: function (e) {
                            if (this.model.unitPrice != null) {
                                this.model.unitPrice = null;
                            }
                            if (this.model.goodId != null) {
                                this.model.goodId = null;
                            }

                            let user = getApp().globalData.userinfo;
                            console.info(user);
                            let obj = {
                                userName: user.userName,
                                userName2: e
                            }
                            var o = this;
                            t.request({
                                url: this.url + "limit/limitManage/userLimits",
                                method: "POST",
                                data: obj,
                                success: function (res) {
                                    o.yfk = 0;
                                    o.kh = 0;
                                    o.xs = 0;
                                    console.info("取到额度", res);
                                    let yfk = res.data.yfk;
                                    if (null != yfk) {
                                        o.yfk = yfk.money;
                                    }
                                    let kh = res.data.kh;
                                    if (null != kh) {
                                        o.kh = kh.money;
                                    }
                                    let xs = res.data.xs;
                                    if (null != xs) {
                                        o.xs = xs.money;
                                    }
                                }
                            })

                        },
                        radioChangeBig: function (e) {
                            this.model.sizepackaging = '大包'
                            this.ischeck = true;
                            this.ischeck1 = false;
                            // console.log(this.model.sizepackaging) 
                        },
                        radioChangeSmall: function (e) {
                            this.model.sizepackaging = '小包'
                            this.ischeck = false;
                            this.ischeck1 = true;
                            // console.log(this.model.sizepackaging)
                        },
                        getWeightGoods: function (e) {
                          console.info("选择规格")
                            var o = this;
                            if (e == null) {
                                return;
                            }
                            if (o.model.customerId == "") {

                              setTimeout(()=>{
                                o.model.sizepackaging = null;
                                o.model.paymentType = null;
                                o.model.unitPrice = null;
                                  t.showToast({
                                      title: "请先选择客户",
                                      icon: "error",
                                      duration: 2e3
                                  });
                              },200)
                             
                               
                                console.info(o.model);
                                return false;
                            }

                            if (o.model.goodId == "") {
                              o.model.unitPrice = null;
                              o.model.sizepackaging = null;
                              setTimeout(()=>{
                              t.showToast({
                                  title: "请先选择商品",
                                  icon: "error",
                                  duration: 2e3
                              });
                          
                          },200)
                              console.info(o.model);
                              return false;
                          }


                            console.info(o.model);
                            t.request({
                                url: this.url + "finishedgoods/finishedgoods/list",
                                method: "GET",
                                data: {
                                    goodsno: o.model.goodId,
                                    state: 0
                                },
                                success: function (res) {
                                    t.request({
                                        url: o.url + "goodsmaintain/goods/byNo/" + o.model.goodId,
                                        method: "GET",
                                        success: function (val) {
                                            t.request({
                                                url: o.url + "goods/GoogsTypePrice/ByNo",
                                                method: "POST",
                                                data: {
                                                    goodsno: o.model.goodId,
                                                    userName: o.model.customerId,
                                                    type:o.model.sizepackaging,
                                                },
                                                success: function (goodVal) {
                                                    let goddsData = goodVal.data.data
                                                    console.info(goddsData);
                                                        o.model.unitPrice = goddsData;
                                                   
                                                    let inventory = val.data.data.inventory;
                                                    if (inventory == null || inventory == 1) {
                                                        // if (console.log(res), 0 != res.data.rows.length) {
                                                        if (0 != res.data.rows.length) {
                                                            // console.log("当前货品库存"), console.log(t.data.rows);

                                                            var s = 0;
                                                            res.data.rows.forEach((function (info) {
                                                                s += parseFloat(info.weight)
                                                            })), o.finWeight = s
                                                        } else o.finWeight = "暂无剩余库存"
                                                    } else {
                                                        o.finWeight = '库存充足';
                                                    }
                                                }
                                            })
                                        }
                                    })

                                }
                            })
                        },
                        bindDateChange: function (t) {
                            this.date = t.detail.value
                        },
                        counttax: function () { //点击计算税费
                            var o = this;
                            // console.log("单价", o.model.unitPrice);
                            if (o.model.unitPrice == 0 || o.model.unitPrice == null || o.model.unitPrice == undefined) {
                                t.showToast({
                                    title: "请填写单价！",
                                    icon: "error",
                                    duration: 2e3
                                });
                                return;
                            }
                            // if(o.model.freight == 0 || o.model.freight == null || o.model.freight == undefined){
                            //     t.showToast({
                            //         title: "请填写运费！",
                            //         icon: "error",
                            //         duration: 2e3
                            //     });
                            //     return ;
                            // }

                            if (o.model.unitPrice - o.model.freight < 0) {
                                t.showToast({
                                    title: "单价不得小于运费！请重新输入！",
                                    icon: "error",
                                    duration: 2e3
                                });
                                return;
                            }

                            //if( o.sl==0){
                            //  console.log(11)
                            t.request({
                                url: this.url + "appLoginRedis/getDictValue",
                                method: "GET",
                                data: {
                                    dictLabel: "税费"
                                },
                                success: function (t) {
                                    o.sl = t.data;
                                    // console.log("税费", o.sl);
                                },
                                fail: function () {},
                                complete: function () {
                                    o.model.taxbtu = 1;
                                    // o.sf = parseFloat((o.model.unitPrice - o.model.unitPrice / o.sl)).toFixed(2);

                                    // 得到含税单价
                                    // let  unmoney = o.model.unitPrice - o.model.freight;
                                    //  得到不含税单价
                                    // let taxpricemoney = parseFloat(unmoney * o.sl / (2 * o.sl - 1)).toFixed(2);  逻辑错误
                                    // let taxpricemoney = parseFloat(unmoney /o.sl ).toFixed(2);
                                    let taxpricemoney = parseFloat(o.model.unitPrice / o.sl).toFixed(2);

                                    // 得到当前单价税费
                                    o.sf = parseFloat(o.model.unitPrice - taxpricemoney).toFixed(2);
                                }
                            })
                            // }

                            //  console.log("点击计算税费",this.model.unitPrice);
                        },
                        counttaxs: function () { //点击计算税费
                            this.model.taxbtu = 0;
                            this.sl = 0;
                            //   console.log("点击计算税费",this.model.unitPrice);
                            this.sf = 0;
                        },
                        bindDateChangeend: function (t) {
                            this.dateend = t.detail.value
                        },
                        initData: function (e) {
                            var o = this;
                            return (0, a.default)(n.default.mark((function i() {
                                var a;
                                return n.default.wrap((function (i) {
                                    while (1) switch (i.prev = i.next) {
                                        case 0:
                                            a = o, o.listData = [], e > 0 && t.request({
                                                url: o.url + "sale/product/list",
                                                method: "GET",
                                                data: {
                                                    orderid: e
                                                },
                                                success: function (e) {
                                                    o.listData = e.data.rows,
                                                    o.listData.forEach(item=>{
                                                      item.sizepackagings=o.showGoodsType(item.sizepackaging);
                                                    }),
                                                    t.request({
                                                        url: o.url + "goodsmaintain/goods/list",
                                                        method: "GET",
                                                        data: {
                                                            type: "2"
                                                        },
                                                        success: function (t) {
                                                            o.goods = [], o.goods = t.data.rows
                                                        },
                                                        fail: function () {},
                                                        complete: function () {
                                                            o.listData.forEach((function (t) {
                                                                var e;
                                                                t.goodsname = (null === (e = a.goods.find((function (e) {
                                                                    return e.goodsno === t.goodsno
                                                                }))) || void 0 === e ? void 0 : e.goodsname) || "null"
                                                            })), o.finalList = Object.assign([], JSON.parse(JSON.stringify(o.listData)))
                                                        }
                                                    })
                                                },
                                                fail: function () {},
                                                complete: function () {}
                                            });
                                        case 3:
                                        case "end":
                                            return i.stop()
                                    }
                                }), i)
                            })))()
                        },
                        getMoney: function () {
                            var t = 0;
                            if (0 != this.listData.length) return this.listData.forEach((function (e) {
                                // t += e.amountofmoney
                                t = 0 == t ? e.amountofmoney : 1 * t + 1 * e.amountofmoney
                                //console.log(t)
                            })), parseFloat(t).toFixed(2)
                        },
                        getWeight: function () {
                            var t = 0;
                            if (0 != this.listData.length) return this.listData.forEach((function (e) {
                                t = 0 == t ? e.weight : 1 * t + 1 * e.weight
                            })), parseFloat(t).toFixed(2)
                        },
                        deleteItem: function (t) {
                            // console.log(t);
                            this.listData.splice(t, 1),
                                this.model = {
                                    id: this.model.id,
                                    customerId: this.model.customerId,
                                    paymentType:this.model.paymentType,
                                    weight: 0,
                                    unitPrice: 0,
                                    taxbtu: 0,
                                    freight: 0,
                                    sizepackaging:null,
                                    goodId:null,
                                    goodsname:null,
                                },
                                this.zje = this.listData.length == 0 ? 0 : parseFloat(this.getMoney()).toFixed(2),
                                this.zzl = this.listData.length == 0 ? 0 : parseFloat(this.getWeight()).toFixed(2)
                            // this.zje = this.zje == NaN?0:this.zje, 
                            // this.zzl = this.zzl == NaN?0:this.zzl
                            // console.log(this.zje)
                        },
                        addgoods: function () {

                            if (this.finWeight == '剩余库存' || ((this.model.weight > this.finWeight || this.finWeight == '暂无剩余库存') && this.finWeight != '库存充足')) t.showToast({
                                title: "库存不足！",
                                icon: "error",
                                duration: 2e3
                            });
                            else {
                                var e = this;
                                // console.log(e.sf);
                                if ("" == e.model.goodId || "" == e.model.weight || "" == e.model.unitPrice || "" == e.model.customerId) t.showToast({
                                    title: "请填写货品信息后进行添加！",
                                    icon: "error",
                                    duration: 2e3
                                });
                                else {
                                    for (var o, i, n = 0; n < e.listData.length; n++)
                                        if (e.listData[n].goodsno == e.model.goodId) return t.showToast({
                                                title: "请勿重复添加！",
                                                icon: "error",
                                                duration: 2e3
                                            }), e.model.unitPrice = 0, void(e.model.weight = 0), e.model.freight = 0,
                                            e.sf = 0, this.model.taxbtu = 0;
                                    e.listData.push({
                                            orderid: null,
                                            goodsname: (null === (o = e.goods.find((function (t) {
                                                return t.goodsno == e.model.goodId
                                            }))) || void 0 === o ? void 0 : o.goodsname) || null,
                                            customername: (null === (i = e.customers.find((function (t) {
                                                return t.customerno == e.model.customerId
                                            }))) || void 0 === i ? void 0 : i.customername) || null,
                                            tax: e.sf == 0 ? 0 : e.sf,
                                            customerno: e.model.customerId,
                                            goodsno: e.model.goodId,
                                            weight: e.model.weight,
                                            sizepackaging: e.model.sizepackaging,  // 大小包
                                            sizepackagings:e.showGoodsType(e.model.sizepackaging) ,  // 大小包
                                            // freight: e.model.freight,   运费含税  e.model.taxbtu==1 代表税价按钮打开
                                            // unitprice:e.model.taxbtu==1? parseFloat(e.model.unitPrice - e.sf-e.model.freight).toFixed(2): parseFloat(e.model.unitPrice).toFixed(2),
                                            // unitprice:e.model.taxbtu==1? parseFloat(e.model.unitPrice - e.sf-parseFloat(e.model.freight/1.1).toFixed(2)).toFixed(2): parseFloat(e.model.unitPrice).toFixed(2),
                                            // freight: e.model.taxbtu==1? parseFloat(e.model.freight/1.1).toFixed(2):e.model.freight,
                                            freight: e.model.freight,
                                            unitprice: e.model.taxbtu == 1 ? parseFloat(e.model.unitPrice - e.sf - e.model.freight).toFixed(2) : parseFloat(e.model.unitPrice).toFixed(2),
                                            amountofmoney: e.model.taxbtu == 1 ? parseFloat(
                                                (e.model.weight * parseFloat((e.model.unitPrice - e.sf)).toFixed(2)) +
                                                (e.model.weight * e.sf)
                                            ).toFixed(2) : parseFloat(
                                                (e.model.weight * parseFloat((e.model.unitPrice - e.sf)).toFixed(2)) +
                                                (e.model.weight * e.model.freight) +
                                                (e.model.weight * e.sf)
                                            ).toFixed(2),
                                        }),
                                        e.model.unitPrice = 0,
                                        e.model.weight = 0,
                                        e.model.freight = 0;
                                    e.sl = 0;
                                    e.sf = 0;
                                    this.model.taxbtu = 0;
                                    e.zje = e.getMoney(),
                                        e.zzl = e.getWeight()
                                    e.ischeck = true;
                                    e.ischeck1 = false;
                                    e.model.sizepackaging = '大包';
                                    wx.showToast({
                                        title: "添加成功！向下滑动查看列表。",
                                        icon: "none",
                                        duration: 2000
                                    });


                                }
                            }
                        },
                        _focusWeight: function (t) {
                            "" == t.detail.value && (t.detail.value = 0);
                            var e = t.detail.value;
                            0 == e && (this.model.weight = "")
                        },
                        _focusUnitPrice: function (t) {
                            "" == t.detail.value && (t.detail.value = 0);
                            var e = t.detail.value;
                            0 == e && (this.model.unitPrice = "")
                        },
                        _freight: function (t) {
                            "" == t.detail.value && (t.detail.value = 0);
                            var e = t.detail.value;
                            0 == e && (this.model.freight = "")
                        },
                        changeTotalPriceByW: function (t) {
                            "" == t.detail.value && (t.detail.value = 0);
                            var e = t.detail.value;
                            e ? this.model.totalPrice = this.model.unitPrice * e : this.model.weight = 0
                        },
                        changeTotalPriceByName: function (a) {
                          console.info(a.detail.value);
                          let val=a.detail.value;
                       
                          let _this=this;
                          console.info(_this);
                          t.request({
                            url: _this.url + "customer/customer/list",
                            method: "GET",
                            data: {
                                createordno: getApp().globalData.userinfo.nickName,
                                customername:val
                            },
                            success: function (t) {
                              _this.customers=t.data.rows;
                            },
                            fail: function () {},
                            complete: function () {}
                        })
                      },
                        changeTotalPriceByP: function (t) {
                            "" == t.detail.value && (t.detail.value = 0);
                            var e = t.detail.value;
                            // console.log(e)
                            e ? this.model.totalPrice = this.model.weight * e : this.model.freight = 0
                        },
                        addObject: function (obj) {
                            console.info("取到传值", obj);
                            obj.state = 1;
                            // 用户编码
                            if (obj.type != 0) {
                                // 用户额度
                                console.info(this.customers)
                                console.info(obj.customerno)
                                let info = this.customers.filter(item => item.customerno == obj.customerno)[0];

                        
                                console.info(info);
                                obj.userName = info.customerno;
                                obj.nickName = info.customername;
                            } else {
                                // 销售额度
                                console.info("进入销售额度判断");
                                let user = getApp().globalData.userinfo;
                                obj.userName = user.userName;
                                obj.nickName = user.nickName;
                            }
                            return obj;
                        },
                        submitForm: function () {
                            var e = this;
                            if (this.listData.length > 0) {
                                getApp().globalData.userinfo.roles[0].roleKey, getApp().globalData.userinfo.userName;
                                var o = getApp().globalData.userinfo.nickName,
                                    i = this;
                                i.model.roleId;
                                var s = (new Date).getTime();
                                let obj = {
                                    paymentType: this.model.paymentType,
                                    limits: i.zje
                                }
                                let x = this.verify(obj, 1);
                                if (x === 1) {
                                    return;
                                }
                                i.$refs.form.validate().then(function () {
                                    var r = (0, a.default)(n.default.mark((function a(r) {
                                        var d, l;
                                        return n.default.wrap((function (n) {
                                            while (1) switch (n.prev = n.next) {
                                                case 0:
                                                    0 != i.model.id ? (t.request({
                                                            url: e.url + "salesdocuments/salesdocuments",
                                                            method: "PUT",
                                                            data: {
                                                                id: i.model.id,
                                                                approverList: ["salessupervisor"],
                                                                customerno: i.model.customerId,
                                                                weight: i.zzl,
                                                                amountofmoney: i.zje,
                                                                maintainpeople: "app修改",
                                                                approver2: i.model.approver2,
                                                                paymentType: i.model.paymentType,
                                                            },
                                                            success: function (o) {
                                                                console.info("修改");
                                                                let objs = {
                                                                    type: i.model.paymentType,
                                                                    limits: i.zje,
                                                                    salesdocumentsId: i.model.id,
                                                                    addUp: 1,
                                                                    customerno: i.model.customerId,
                                                                    state:1,
                                                                }
                                                                let val = i.addObject(objs);
                                                                // t.request({
                                                                //     url: i.url + "limit/limitManageLog/limitManage",
                                                                //     method: "POST",
                                                                //     data: val,
                                                                //     success: function (res) {
                                                                        var n = [];
                                                                        i.finalList.forEach((function (t) {
                                                                            n.push(t.id)
                                                                        }));
                                                                        t.request({
                                                                            url: e.url + "sale/product/" + n,
                                                                            method: "DELETE",
                                                                            success: function (t) {},
                                                                            fail: function () {},
                                                                            complete: function () {
                                                                                i.listData.forEach((function (o) {
                                                                                    o.orderid = i.model.id, t.request({
                                                                                        url: e.url + "sale/product",
                                                                                        method: "POST",
                                                                                        data: o,
                                                                                        success: function (t) {},
                                                                                        fail: function () {},
                                                                                        complete: function () {
                                                                                            e.initData(parseInt(e.model.id))
                                                                                        }
                                                                                    })
                                                                                }))
                                                                            }
                                                                        })
                                                                //     }
                                                                // })

                                                            },
                                                            fail: function () {},
                                                            complete: function () {
                                                                t.request({
                                                                    url: e.url + "driverorders/driverorders/list",
                                                                    method: "GET",
                                                                    data: {
                                                                        orderid: i.model.id
                                                                    },
                                                                    success: function (t) {
                                                                        t.data.total > 0 ? i.str = t.data.rows : i.str = []
                                                                    },
                                                                    fail: function () {},
                                                                    complete: function () {
                                                                        i.str.length > 0 && t.request({
                                                                            url: e.url + "salesdocuments/salesdocuments",
                                                                            method: "PUT",
                                                                            data: {
                                                                                id: i.model.id,
                                                                                state: 0,
                                                                                maintainpeople: o
                                                                            },
                                                                            success: function (t) {},
                                                                            fail: function () {},
                                                                            complete: function () {}
                                                                        })
                                                                    }
                                                                })
                                                            }
                                                        }),
                                                        setTimeout((function () {
                                                            // console.log(e.sid)
                                                            if (this.orderStateUpdate) {
                                                                t.showToast({
                                                                    title: "修改成功"
                                                                })
                                                            }
                                                            this.orderStateUpdate = true;

                                                            // }), 500), 0 <= e.sid ? (console.log(e.sid), d = e.model.id + "@" + e.model.ordertime, t.navigateTo({
                                                        }), 500), 0 <= e.sid ? (d = e.model.id + "@" + e.model.ordertime, t.navigateTo({
                                                            url: "/pages/main/sales/adddriver?id=".concat(d)
                                                        })) : t.navigateTo({
                                                            url: "/pages/main/sales/my"
                                                        })) : (l = getApp().globalData.userinfo,
                                                        t.request({
                                                            url: e.url + "salesdocuments/salesdocuments",
                                                            method: "POST",
                                                            data: {
                                                                id: s,
                                                                approverList: ["salessupervisor"],
                                                                customerno: i.model.customerId,
                                                                deliverytime: i.dateend,
                                                                weight: i.zzl,
                                                                amountofmoney: i.zje,
                                                                goodsno: i.model.goodId,
                                                                createname: l.nickName,
                                                                state: 4,
                                                                approver2: i.model.approver2,
                                                                paymentType: i.model.paymentType,
                                                                salesState: 0,
                                                                operatorcode:getApp().globalData.userinfo.userName,
                                                            },
                                                            success: function (o) {
                                                                console.info("新增");

                                                                let objs = {
                                                                    type: i.model.paymentType,
                                                                    limits: i.zje,
                                                                    salesdocumentsId: s,
                                                                    addUp: 0,
                                                                    customerno: i.model.customerId,
                                                                    state:1,
                                                                }
                                                                let val = i.addObject(objs);
                                                                // t.request({
                                                                //     url: i.url + "limit/limitManageLog/limitManage",
                                                                //     method: "POST",
                                                                //     data: val,
                                                                //     success: function (res) {},
                                                                //     complete: function () {
                             
                                                                        console.log(i.listData);
                                                                        i.listData.forEach((function (o) {
                                                                            o.orderid = s,
                                                                                t.request({
                                                                                    url: e.url + "sale/product",
                                                                                    method: "POST",
                                                                                    data: o,
                                                                                    complete: function () {
                                                                                        e.listData = []
                                                                                    }
                                                                                })
                                                                        }))
                                                                //     }
                                                                // })
                                                            },
                                                            fail: function () {},
                                                            complete: function () {
                                                                e.model.approver2 = ""
                                                            }
                                                            // }), console.log("订单状态：" + e.saleOrderState), e.saleOrderState ? t.switchTab({
                                                        }), e.saleOrderState ? t.switchTab({
                                                            url: "/pages/main/index"
                                                        }) : (d = s + "@" + i.dateend, t.navigateTo({
                                                            url: "/pages/main/sales/adddriver?id=".concat(d)
                                                        })));
                                                case 1:
                                                case "end":
                                                    return n.stop()
                                            }
                                        }), a)
                                    })));
                                    return function (t) {
                                        return r.apply(this, arguments)
                                    }
                                }()).catch((function (t) {}))
                            } else t.showToast({
                                title: "请填写货品信息后进行添加！",
                                icon: "error",
                                duration: 2e3
                            })
                        },
                        verify: function (data, type) {
                            console.info(data);
                            let _this = this;
                            let a = 0;
                            // 新增
                            if (type == 1) {
                                let sum;
                                // 销售
                                if (data.paymentType == 0) {
                                    sum = this.xs;
                                } else if (data.paymentType == 1) {
                                    sum = this.kh;
                                    // 客户
                                } else {
                                    sum = this.yfk;
                                    // 预付款
                                }
                                if (data.limits > sum) {
                                    t.showToast({
                                        title: "额度不够",
                                        icon: "error",
                                        duration: 2e3
                                    })
                                    a = 1;
                                }
                            } else {
                                _this.showLimit(data.customerno);
                                // 修改
                                t.request({
                                    url: this.url + "salesdocuments/salesdocuments/" + data.customerno,
                                    method: "GET",
                                    success: function (res) {
                                        console.info(res);
                                        let info = res.data.data;

                                        // 未修改前总金额
                                        let sum = info.amountofmoney;
                                        // 销售
                                        if (data.paymentType == 0) {
                                            sum += _this.xs;
                                        } else if (data.paymentType == 1) {
                                            // 客户
                                            sum += _this.kh;
                                        } else {
                                            // 预付款
                                            sum += _this.yfk;
                                        }
                                        if (data.limits > sum) {
                                            t.showToast({
                                                title: "额度不够",
                                                icon: "error",
                                                duration: 2e3
                                            })
                                            a = 1;
                                        }
                                    }
                                })

                            }
                            return a;
                        },
                        submitForms: function () {
                            var e = this;
                            if (this.listData.length > 0) {
                                getApp().globalData.userinfo.roles[0].roleKey, getApp().globalData.userinfo.userName;
                                var o = getApp().globalData.userinfo.nickName,
                                    i = this;
                                i.model.roleId;

                                let obj = {
                                    paymentType: this.model.paymentType,
                                    limits: i.zje,
                                    customerno: i.model.id
                                }
                                let x = this.verify(obj, 0);
                                if (x === 1) {
                                    return;
                                }
                                var s = (new Date).getTime();
                                i.$refs.form.validate().then(function () {
                                    var r = (0, a.default)(n.default.mark((function a(r) {
                                        var d, l;
                                        return n.default.wrap((function (n) {
                                            while (1) switch (n.prev = n.next) {
                                                case 0:
                                                    0 != i.model.id ? (t.request({
                                                            url: e.url + "salesdocuments/salesdocuments",
                                                            method: "PUT",
                                                            data: {
                                                                id: i.model.id,
                                                                approverList: ["salessupervisor"],
                                                                customerno: i.model.customerId,
                                                                weight: i.zzl,
                                                                amountofmoney: i.zje,
                                                                maintainpeople: "app修改",
                                                                approver2: i.model.approver2
                                                            },
                                                            success: function (o) {

                                                                console.info("修改");
                                                                let objs = {
                                                                    type: i.model.paymentType,
                                                                    limits: i.zje,
                                                                    salesdocumentsId: i.model.id,
                                                                    addUp: 1,
                                                                    customerno: i.model.customerId,
                                                                    state:1,
                                                                }
                                                                let val = i.addObject(objs);
                                                                // t.request({
                                                                //     url: i.url + "limit/limitManageLog/limitManage",
                                                                //     method: "POST",
                                                                //     data: val,
                                                                //     success: function (res) {
                                                                        var n = [];
                                                                        i.finalList.forEach((function (t) {
                                                                            n.push(t.id)
                                                                        })), t.request({
                                                                            url: e.url + "sale/product/" + n,
                                                                            method: "DELETE",
                                                                            success: function (t) {},
                                                                            fail: function () {},
                                                                            complete: function () {
                                                                                i.listData.forEach((function (o) {
                                                                                    o.orderid = i.model.id, t.request({
                                                                                        url: e.url + "sale/product",
                                                                                        method: "POST",
                                                                                        data: o,
                                                                                        success: function (t) {},
                                                                                        fail: function () {},
                                                                                        complete: function () {
                                                                                            e.initData(parseInt(e.model.id))
                                                                                        }
                                                                                    })
                                                                                }))
                                                                            }
                                                                        })
                                                                //     }
                                                                // })

                                                            },
                                                            fail: function () {},
                                                            complete: function () {
                                                                t.request({
                                                                    url: e.url + "driverorders/driverorders/list",
                                                                    method: "GET",
                                                                    data: {
                                                                        orderid: i.model.id
                                                                    },
                                                                    success: function (t) {
                                                                        t.data.total > 0 ? i.str = t.data.rows : i.str = []
                                                                    },
                                                                    fail: function () {},
                                                                    complete: function () {
                                                                        i.str.length > 0 && t.request({
                                                                            url: e.url + "salesdocuments/salesdocuments",
                                                                            method: "PUT",
                                                                            data: {
                                                                                id: i.model.id,
                                                                                state: 0,
                                                                                maintainpeople: o
                                                                            },
                                                                            success: function (t) {},
                                                                            fail: function () {},
                                                                            complete: function () {}
                                                                        })
                                                                    }
                                                                })
                                                            }
                                                        }),
                                                        setTimeout((function () {
                                                            // console.log(e.sid)
                                                            t.showToast({
                                                                title: "修改成功"
                                                            })
                                                            // }), 500), 0 <= e.sid ? (console.log(e.sid), d = e.model.id + "@" + e.model.ordertime, t.redirectTo({
                                                        }), 500), 0 <= e.sid ? (d = e.model.id + "@" + e.model.ordertime, t.redirectTo({
                                                            url: "/pages/main/sales/my"
                                                            //url: "/pages/main/sales/adddriver?id=".concat(d)
                                                        })) : t.redirectTo({
                                                            url: "/pages/main/sales/my"
                                                        })) : (l = getApp().globalData.userinfo, t.request({
                                                        url: e.url + "salesdocuments/salesdocuments",
                                                        method: "POST",
                                                        data: {
                                                            id: s,
                                                            approverList: ["salessupervisor"],
                                                            customerno: i.model.customerId,
                                                            deliverytime: i.dateend,
                                                            weight: i.zzl,
                                                            amountofmoney: i.zje,
                                                            goodsno: i.model.goodId,
                                                            createname: l.nickName,
                                                            state: 4,
                                                            approver2: i.model.approver2
                                                        },
                                                        success: function (o) {
                                                            debugger;
                                                            i.listData.forEach((function (o) {
                                                                o.orderid = s, t.request({
                                                                    url: e.url + "sale/product",
                                                                    method: "POST",
                                                                    data: o,
                                                                    success: function (t) {},
                                                                    fail: function () {},
                                                                    complete: function () {}
                                                                })
                                                            }))
                                                        },
                                                        fail: function () {},
                                                        complete: function () {
                                                            e.listData = [], e.model.approver2 = ""
                                                        }
                                                        // }), console.log("订单状态：" + e.saleOrderState), e.saleOrderState ? t.switchTab({
                                                    }), e.saleOrderState ? t.switchTab({
                                                        url: "/pages/main/index"
                                                    }) : (d = s + "@" + i.dateend, t.navigateTo({
                                                        url: "/pages/main/sales/my"
                                                        // url: "/pages/main/sales/adddriver?id=".concat(d)
                                                    })));
                                                case 1:
                                                case "end":
                                                    return n.stop()
                                            }
                                        }), a)
                                    })));
                                    return function (t) {
                                        return r.apply(this, arguments)
                                    }
                                }()).catch((function (t) {}))
                            } else t.showToast({
                                title: "请填写货品信息后进行添加！",
                                icon: "error",
                                duration: 2e3
                            })
                        },
                        StagingFrom: function () {

                            // 模拟通知


                            this.submitForm()
                        },
                        StagingFromDri: function () {
                            let subType = this.JudgmentType(this.model.paymentType);
                            console.info("判断使用权限", subType);
                            if (!subType) {
                                return;
                            }
                            this.submitForm();
                            // if (this.listData.length == 0) return;
                            // setTimeout((function () {
                            //     t.showToast({
                            //         title: "订单创建成功"
                            //     })
                            // }), 500)
                        },
                        StagingFromDriupdate: function () {
                            this.submitForm();
                            this.orderStateUpdate = false;
                            //console.log('测试：',this.listData)
                            if (this.listData.length == 0) return;
                            //     setTimeout((function () {
                            //        t.showToast({
                            //            title: "订单创建成功"
                            //        })
                            //    }), 500)
                        },
                        submitBack: function () {
                            this.model.status = 0, t.showToast({
                                title: "撤销成功"
                            })
                        },
                        querygoodsList: function () {}
                    },
                    onHide: function () {
                        // console.log("离开页面")
                    },
                    onShow: function () {
                        //   console.log("show")
                    },
                    onLoad: function (e) {
                        var o = this;
                        // console.log(e), 
                        this.model.id = 0, this.model.customerId = "", this.model.goodId = "", this.model.weight = "", this.model.unitPrice = "", this.model.totalPrice = 0, this.model.roleId = "", this.model.status = 0, this.customers = [], this.goods = [], this.listData = [], e.id && (this.model.id = e.id), this.initData(parseInt(e.id)), t.request({
                                url: this.url + "customer/customer/list",
                                method: "GET",
                                data: {
                                    createordno: getApp().globalData.userinfo.nickName
                                },
                                success: function (t) {
                                    o.customers = t.data.rows
                                },
                                fail: function () {},
                                complete: function () {}
                            }),
                            t.request({
                                url: this.url + "appLoginRedis/getDictValue",
                                method: "GET",
                                data: {
                                    dictLabel: "税费"
                                },
                                success: function (t) {
                                    //o.sl = t.data;
                                },
                                fail: function () {},
                                complete: function () {}
                            }),
                            // 支付类型字典
                            t.request({
                                url: this.url + "system/dict/data/type/payment_type",
                                method: "GET",
                                success: function (t) {
                                    console.info("支付类型字典");
                                    console.info(t);
                                    o.paymentTypes = t.data.data;
                                },
                                fail: function () {},
                                complete: function () {}
                            }),
                            //产品规格字典
                            t.request({
                              url: this.url + "system/dict/data/type/goods_type",
                              method: "GET",
                              success: function (t) {
                                  console.info("产品规格字典");
                                  console.info(t);
                                  o.goodsTypes = t.data.data;
                              },
                              fail: function () {},
                              complete: function () {}
                          }),
                            t.request({
                                url: this.url + "goodsmaintain/goods/list",
                                method: "GET",
                                data: {
                                    type: "2"
                                },
                                success: function (t) {
                                    o.goods = t.data.rows
                                },
                                fail: function () {},
                                complete: function () {}
                            }), t.request({
                                url: this.url + "apiunattended/apiunattended/getRolesAll",
                                method: "GET",
                                data: {
                                    type: "2"
                                },
                                success: function (t) {
                                    o.roles = t.data
                                },
                                fail: function () {},
                                complete: function () {}
                            }), e.id && (t.setNavigationBarTitle({
                                title: "修改销售单"
                            }), t.request({
                                url: this.url + "driverorders/driverorders/list",
                                method: "GET",
                                data: {
                                    orderid: e.id,
                                    ordertype: 2
                                },
                                success: function (t) {
                                    t.data.rows.length > 0 && (o.sid = 1)
                                },
                                fail: function () {},
                                complete: function () {}
                            }), t.request({
                                url: this.url + "salesdocuments/salesdocuments/".concat(e.id),
                                method: "GET",
                                data: {},
                                success: function (t) {
                                    o.model.approver2 = t.data.data.approver2, o.model.id = t.data.data.id, o.model.customerId = t.data.data.customerno, o.zzl = t.data.data.weight,
                                        o.zje = t.data.data.amountofmoney,
                                        o.model.unitPrice = t.data.data.unitprice, o.model.totalPrice = t.data.data.amountofmoney, o.model.ordertime = t.data.data.deliverytime,
                                        o.model.paymentType = t.data.data.paymentType;
                                    var e = t.data.data.approver1,
                                        i = e.lastIndexOf(",");
                                    e = e.substring(0, i), o.model.roleId = e
                                },
                                fail: function () {},
                                complete: function () {}
                            }))
                    }
                };
                e.default = r
            }).call(this, o("543d")["default"])
        },
        d543: function (t, e, o) {
            "use strict";
            var i = o("588d"),
                n = o.n(i);
            n.a
        }
    },
    [
        ["89a5", "common/runtime", "common/vendor"]
    ]
]);